var a = 0;
var text;
var selects; //记录玩家的选项
var buynum = 0;
var itemlist = Array(
Array(1000071, 20),
Array(1001094, 20),
Array(1051386, 20), 
Array(1050315, 20),
Array(1702491, 20),
Array(1102672, 20),
Array(1072913, 20),
Array(1072868, 20),
Array(1001098, 20),
Array(1050424, 20),
Array(1051492, 20),
Array(1053294, 20),
Array(1053293, 20),
Array(1702687, 20),
Array(1004602, 20),
Array(1050389, 20),
Array(1051459, 20),
Array(1102864, 20),
Array(1702628, 20),
Array(1004642, 20), 
Array(1051465, 20),
Array(1050394, 20),
Array(1073105, 20),
Array(1102876, 20),
Array(1702637, 20),
Array(1004190, 20),
Array(1042320, 20),
Array(1102705, 20),
Array(1072942, 20),
Array(1004486, 20),
Array(1051434, 20),
Array(1050364, 20),
Array(1073056, 20),
Array(1702586, 20),
Array(1004739, 20),
Array(1051491, 20),
Array(1050423, 20),
Array(1071096, 20),
Array(1070079, 20),
Array(1102920, 20),
Array(1004716, 20),
Array(1050422, 20),
Array(1071095, 20),
Array(1070078, 20),
Array(1102915, 20),
Array(1702676, 20),
Array(1004816, 20),
Array(1051499, 20),
Array(1050431, 20),
Array(1073163, 20),
Array(1102946, 20),
Array(1702703, 20),
Array(1004852, 20),
Array(1051506, 20),
Array(1073176, 20),
Array(1102964, 20),
Array(1702717, 20),
Array(1004948, 20),
Array(1004947, 20),
Array(1050454, 20),
Array(1051521, 20),
Array(1073212, 20),
Array(1103010, 20),
Array(1702755, 20),
Array(1005000, 20),
Array(1050468, 20),
Array(1051535, 20),
Array(1073237, 20),
Array(1103035, 20),
Array(1702779, 20)
);

function start() {
    a = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 1)
            a++;
        else
            a--;
        if (a == -1) {
            cm.dispose();
        } else if (a == 0) {
			text = "#r尊敬的PPMS冒险岛玩家您好,您可以使用#v4310234#兑换以下物品~\r\n您有以下几种方法可以获得#v4310234#\r\n\r\n#k参加敲打箱子.头脑之神问答.市场不定时天降礼包.\r\n#b";
			for (var i=0; i<itemlist.length; i++) {
				text += "#L" + i + "##i" + itemlist[i] + ":##t" + itemlist[i] + "# - #r"+itemlist[i][1]+"#b 闪耀币  \r\n";
				if (i != 0 && (i+1) % 5 == 0) {
					text += "\r\n";
				}
			}
            cm.sendSimple(text);
        } else if (a == 1) {
			selects = selection;
            cm.sendGetNumber("请输入你请你输入想要兑换的数量\r\n\r\n#r1个需要" + itemlist[selects][1] + "个#b闪耀币#k", 1, 0, 999999);
        } else if (a == 2) {
            buynum = selection;
            cm.sendNext("你想兑换" + buynum + "个#r#i" + itemlist[selects][0] + "##k？\r\n你将使用掉" + (buynum * itemlist[selects][1]) + "闪耀币。");
        } else if (a == 3) {
            if (cm.haveItem(4310234,buynum * itemlist[selects][1])) {
                cm.gainItem(4310234, -buynum * itemlist[selects][1]);
                cm.gainItem(itemlist[selects][0], buynum);
                cm.sendOk("兑换成功了！");
                cm.dispose();
            } else {
                cm.sendOk("对不起，你没有足够的闪耀币。");
                cm.dispose();
            }
        }
    }//mode
}//f